﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using HiStaff.Control;
using HiStaff.Domain.HU;
using HiStaff.iSystem;
using System.Data;

namespace HiStaff.Base
{
    public class Common
    {
        #region Combobox
        //Load Combobox don vi ky hop dong
        public static void BindOrgSignContractToCombobox(HiComboBox combobox)
        {
            DataTable lstCombo = Service.ExcuteStoreToDataTable("PRS_HU_SIGNCONTRACT");
            combobox.DisplayMember = "ORGNAME";
            combobox.ValueMember = "ORGCONTRACT";
            combobox.DataSource = lstCombo;
        }

        #endregion

        #region CheckData
        /// <summary>
        /// Kiem tra Effectdate < Expiredate
        /// </summary>
        /// <param name="Effectdate"></param>
        /// <param name="ExpireDate"></param>
        /// <returns></returns>
        public static bool CheckEffectDateAndExpireDate(HiDatePicker Effectdate, HiDatePicker ExpireDate)
        {
            if (ExpireDate != null && Effectdate != null)
            {
                if (Effectdate.Value > ExpireDate.Value)
                {
                    return false;
                }
            }
            return true;
        }

        /// <summary>
        /// Kiem tra trung so CMND
        /// </summary>
        /// <param name="sCODE"></param>
        /// <param name="sIDNO"></param>
        /// <returns></returns>
        public static bool CheckIDNo(string sCODE, string sIDNO)
        {
            DataTable dtArg = new DataTable("T");
            dtArg.Columns.Add("CODE");
            dtArg.Columns.Add("IDNO");
            DataRow dr = dtArg.NewRow();
            dr[0] = sCODE;
            dr[1] = sIDNO;
            dtArg.Rows.Add(dr);

            DataTable lstEmployee = Service.ExcuteStoreToDataTable("PRS_CHK_HU_IDNO", dtArg);
            if ((decimal)lstEmployee.Rows[0][0] == 1)
            {
                return false;
            }
            return true;
        }
        #endregion
    }
}
